package com.ruima.study.arithmetic.sortdemo.practice;

import java.util.Arrays;

/**
 * <p>
 * <p>等差数组</p>
 * <p>
 * <p>Copyright (c) 2024/11/15 11:08, 科大讯飞 All Rights Reserve</p>
 *
 * @author ruima6
 * @version [V1.0]
 */
public class demo3 {

    public static void main(String[] args) {
        int[] arr = {3, 5, 2, 7};
        System.out.println(new demo3().canMakeArithmeticProgression(arr));
    }

    public boolean canMakeArithmeticProgression(int[] arr) {
        Arrays.sort(arr);
        int val = arr[1] - arr[0];
        for (int i = 1; i < arr.length - 1; i++) {
            if (arr[i + 1] - arr[i] != val) {
                return false;
            }
        }
        return true;
    }

}
